<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title>红包雨</title>
    <link rel="stylesheet" type="text/css" href="../addons/jy_h5game/resource/xianchang/css/basic.css">	
	<link rel="stylesheet" href="../addons/jy_h5game/resource/xianchang/css/repack_shake.css" type="text/css">
	<link rel="stylesheet" href="../addons/jy_h5game/resource/xianchang/css/grab_redenvelop.css" type="text/css">
	<script src="../addons/jy_h5game/resource/xianchang/js/tool.js" type="text/javascript" charset="utf-8"></script>
    <script src="../addons/jy_h5game/resource/xianchang/js/base3.js" type="text/javascript" charset="utf-8"></script>
	<script src="../addons/jy_h5game/resource/xianchang/js/screen_repack.js" type="text/javascript" charset="utf-8"></script>
	<script src="../addons/jy_h5game/resource/xianchang/js/jquery.nicescroll.min.js" type="text/javascript" charset="utf-8"></script>
<style>
	.pop_winninglist dl dd.list li.b_money {
		background-color: #3a80ff;
	}
		
	
		.redenvelop_box .redenvelop_list .redenvelop1{background: url("../addons/jy_h5game/resource/xianchang/images/redpack/redenvelop_01.png") no-repeat;}
	
		.redenvelop_box .redenvelop_list .redenvelop2 {background: url("../addons/jy_h5game/resource/xianchang/images/redpack/redenvelop_02.png") no-repeat;}
	
	
		.redenvelop_box .redenvelop_list .redenvelop3 {background: url("../addons/jy_h5game/resource/xianchang/images/redpack/redenvelop_03.png") no-repeat;}
	
		.redenvelop_box .redenvelop_list .redenvelop4 {background: url("../addons/jy_h5game/resource/xianchang/images/redpack/redenvelop_04.png") no-repeat;}
	
	
		.redenvelop_box .redenvelop_list .redenvelop5 {background: url("../addons/jy_h5game/resource/xianchang/images/redpack/redenvelop_05.png") no-repeat;}

		.redenvelop_box .redenvelop_list .redenvelop6 {background: url("../addons/jy_h5game/resource/xianchang/images/redpack/redenvelop_06.png") no-repeat;}
	
		.redenvelop_box .redenvelop_list .redenvelop7 {background: url("../addons/jy_h5game/resource/xianchang/images/redpack/redenvelop_07.png") no-repeat;}
	
	
	</style>
</head>
 <div >
<style>
.fe-floatback {width: 32px; position: fixed; top: 4px;left:4px; text-align: center; z-index: 1003;}
.fe-floatback a{ display: block; width: 32px; height: 32px;}
.fe-floatback a img{width:32px;height:32px;opacity:0.5;}
</style>
<div class="fe-floatback">
		<a href="{$backurl}">
			<img src="../core/resource/images/goback.png"></i>
		</a>
</div>  
      <div class="main">
        <!-- 背景动画 -->
        <div class="bg_rotate animate_rotate"></div>
        <!-- 钱袋 -->
        <div class="top_package">
          <div class="top_package_in"></div>
          <div class="top_package_out"></div>
          <!-- <p class="countNum">倒计时
            <b class="sec">60</b>
            <b>:</b>
            <b class="hm">00</b></p> -->
        </div>
        <div onclick="cj()" class="redenvelop_box" style="display:block;">
          <ul class="redenvelop_list" style="margin:0px;padding:0px"></ul>
        </div>
        <div class="title"></div>
        <a href="javascript:;" class="start" onclick="game_start()" id="start"></a>
        <!-- 页面底部元素 -->
        <div class="bottom_sphere" style="bottom:0px"></div>
        <div class="bottom_money" style="bottom:0px"></div>
        <div class="bottom_phone" style="bottom:0px"></div>
        <!-- 参与用户列表 -->
        <div class="left_userlist">
          <div class="list_img">
            <ul class="clearfix">
              
            </ul>
          </div>
         
        </div>
        <!-- 中奖名单列表 -->
        
      </div>
      <!-- 弹窗 -->
      <div class="pop_mask"></div>
      
      <!-- 单个中奖弹窗 -->
      <div class="pop_winning clearfix">
        <img src="" class="user_photo">
        <div class="user_info">
          <p>实物奖品</p>
          <span>恭喜ad司法获得</span></div>
        <img src="" class="prize_img"></div>
     
    </div>
	<div id='ddd' style="display:none"></div>
    <script type="text/javascript">
		function senddh(){
			$('.screen_show').css('opacity','1');
		}
	</script>
    <script>
	$(function() {
        // js生成红包个数
        for (var i = 1; i <= 7; i++) {
		
          if (i == 1) {
            for (var j = 1; j <= 1; j++) {
              $('.redenvelop_box .redenvelop_list').append('<li class="redenvelop' + i + '" id="redenvelop' + i + '_' + j + '"></li>');
            }
          }
          if (i == 2) {
            for (var j = 1; j <= 1; j++) {
              $('.redenvelop_box .redenvelop_list').append('<li class="redenvelop' + i + '" id="redenvelop' + i + '_' + j + '"></li>');
            }
          }
          if (i == 3) {
            for (var j = 1; j <= 2; j++) {
              $('.redenvelop_box .redenvelop_list').append('<li class="redenvelop' + i + '" id="redenvelop' + i + '_' + j + '"></li>');
            }
          }
          if (i == 4) {
            for (var j = 1; j <= 2; j++) {
              $('.redenvelop_box .redenvelop_list').append('<li class="redenvelop' + i + '" id="redenvelop' + i + '_' + j + '"></li>');
            }
          }
          if (i == 5) {
            for (var j = 1; j <= 3; j++) {
              $('.redenvelop_box .redenvelop_list').append('<li class="redenvelop' + i + '" id="redenvelop' + i + '_' + j + '"></li>');
            }
          }
          if (i == 6) {
            for (var j = 1; j <= 3; j++) {
              $('.redenvelop_box .redenvelop_list').append('<li class="redenvelop' + i + '" id="redenvelop' + i + '_' + j + '"></li>');
            }
          }
          if (i == 7) {
            for (var j = 1; j <= 4; j++) {
              $('.redenvelop_box .redenvelop_list').append('<li class="redenvelop' + i + '" id="redenvelop' + i + '_' + j + '"></li>');
            }
          }
        }

        $('#start').on('click',
        function() {
          //清空当前中奖数据
          $(".pop_winninglist_a ul li").remove();
         
         
        });

        // 按键判断
        document.onkeydown = function(event) {
          var e = event || window.event || arguments.callee.caller.arguments[0];
			  if (e && e.keyCode == 13) {
				// 回车，开始游戏
				if ($('.countNum').is(':hidden')) {
				  $('#start').click();
				}
			  } else if (e && e.keyCode == 32) {
				// 空格，缩放二维码
				$('.pop_weixin_ecode').toggle();
			  } else if (e && e.keyCode == 80) {
				// p键，显示、隐藏结果页
				if ($('.pop_winninglist .btn_close').is(':hidden')) {
				  $('.right_winninglist .pop_winninglist_a').click();
				} else {
				  $('.pop_winninglist .btn_close').click();
				}
			  } else if (e && e.keyCode == 37) {
				/* 左切换 */
				parent.leftRightSwitch('prev');
			  } else if (e && e.keyCode == 39) {
				/* 右切换 */
				parent.leftRightSwitch('next');
			  }
        }

        // 再玩一次，重新开始红包雨效果
        $('#btn_replay').click(function() {
			window.location.reload();
        });
	 });
		 
      function cj() {
	  if(scope.pagedata.start==1){
		var rate = scope.pagedata.jx[0].rate; 
		var hbLow = scope.pagedata.jx[0].hbLow;
		var hbHigh = scope.pagedata.jx[0].hbHigh;
		var num = Math.round(Math.random()*100);
		
		
		if(num < rate){
			var money = parseFloat(Math.round((Math.random()*(hbHigh-hbLow)*100))/100) + parseFloat(hbLow);
			alert('恭喜获得'+ money+'元红包');
			
		}else{
			alert('没中奖');
		}
		}
	  }
      // 点击go开始红包雨效果
      function game_start() {
		scope.pagedata.start=1;
        $('#start').fadeOut('fast');
        $('.title').fadeOut('slow');
        $('.tips').fadeOut('slow');
        $('.redenvelop_box').show();
        $('.countNum').show();
        $('.right_winninglist .pop_winninglist_a').removeClass('pop_winninglist_a');

        $('.top_package').children('div').removeClass('shake-one').addClass('shake shake-rotate');

        for (var i = 1; i <= 7; i++) {
          if (i == 1) {
            for (var j = 1; j <= 1; j++) {
              ani_redenvelop('#redenvelop' + i + '_' + j + '', 1500);
            }
          }
          if (i == 2) {
            for (var j = 1; j <= 1; j++) {
              ani_redenvelop('#redenvelop' + i + '_' + j + '', 1200);
            }
          }
          if (i == 3) {
            for (var j = 1; j <= 2; j++) {
              ani_redenvelop('#redenvelop' + i + '_' + j + '',900 + (j - 1) * 400);
            }
          }
          if (i == 4) {
            for (var j = 1; j <= 2; j++) {
              ani_redenvelop('#redenvelop' + i + '_' + j + '', 1050 + (j - 1) * 300);
            }
          }
          if (i == 5) {
            for (var j = 1; j <= 3; j++) {
              ani_redenvelop('#redenvelop' + i + '_' + j + '', 1000 + (j - 1) * 200);
            }
          }
          if (i == 6) {
            for (var j = 1; j <= 3; j++) {
              ani_redenvelop('#redenvelop' + i + '_' + j + '', 800 + (j - 1) * 200);
            }
          }
          if (i == 7) {
            for (var j = 1; j <= 4; j++) {
              var ani_time = 750 + (j - 1) * 100;
              setTimeout("ani_redenvelop('#redenvelop" + i + "_" + j + "'," + ani_time + ")", (j - 1) * 200);
            }
          }
			}
        }

   /*     // 有用户中奖弹窗显示信息效果
        activity_screen_record();

        // 判断倒计时是否结束
        var countNum = parseInt($('.countNum b.sec').text());
        var duration = countNum * 1000;
        var endTime = new Date().getTime() + duration;
        var countNum_timer = setInterval(function() {

          var ssNum_n = (endTime - new Date().getTime()) / 1000;
          var ssNum_sec = parseInt(ssNum_n) > 0 ? parseInt(ssNum_n) : 0;
          var ssNum_hm = ssNum_n.toFixed(2).substr( - 2, 2);

          $('.countNum b.sec').text(ssNum_sec);
          $('.countNum b.hm').text(ssNum_hm);

          //if( ssNum_sec<=0 && ssNum_hm<=0){
          if (ssNum_n <= 0) {
            clearInterval(countNum_timer);
			activity_is_end(); 
            setTimeout(function() {
              $('.countNum').html('游戏已结束<b class="sec" style="display:none">0</b>');
            },
            500);
			
            $('.right_winninglist .list').addClass('pop_winninglist_a');

            //清除红包抖动动画
            $('.top_package').children('div').removeClass('shake-rotate').addClass('shake-one');
            setTimeout(function() {
              $('.top_package').children('div').removeClass('shake shake-one');
            },
            800);

            // 清除中奖名单显示动画	
            clearTimeout(ani_winning_timer);
            clearTimeout(record_timer);
            $('.pop_winning').hide();

            //所有中奖记录
           // record_all();
          }
        },
        10);

      };

      //活动是否能结束
      function activity_is_end() {
        $.post("{php echo $this->createMobileUrl('end_redpack',array('rid'=>$rid,'rotate_id'=>$redpack['id']))}",{});
      }

      //所有中奖记录
      function record_all() {
        var data = {
        };

        $.post("{php echo $this->createMobileUrl('all_redpack_record',array('rid'=>$rid,'rotate_id'=>$redpack['id']))}", data,
        function(e) {
          var list = e.list;
          var html = '';
          if (list.length > 0) {
            for (var i in list) {
				var thtml = ''
				if(bd_show ==1 && lottory_show.length>0){
					for(var y=0;y<lottory_show.length;y++){
					 if(lottory_show[y]!='mobile'){
						thtml += "&nbsp;&nbsp;&nbsp;"+list[i].bd_data[lottory_show[y]]||' ';	
					  }else{
						list[i].bd_data[lottory_show[y]] = list[i].bd_data[lottory_show[y]].replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
						thtml += "&nbsp;&nbsp;&nbsp;"+list[i].bd_data[lottory_show[y]]||' ';
					  }
					}	
				}else{
					thtml += list[i].nick_name;
				}
                html += '<li class="b_money">\
						<img src="' + list[i].avatar + '" class="user_photo">\
						<div class="user_name">' + thtml + '</div>\
						<div class="prize_info">\
						<p>' + list[i].money + '元</p>\
						<span>红包</span>\
						</div>\
						</li>';
            }
          }
          $('.pop_winninglist dl dd ul').html(html);
          $('.pop_winninglist').show(500);
          $('.pop_mask').show();
          // 设置中间弹框滚动条样式
          $(".pop_winninglist .list").niceScroll(".pop_winninglist .list ul", {
            cursorcolor: "#0c52d2",
            cursoropacitymin: '1',
            cursorborder: '0',
            cursorborderradius: '0'
          });
        },
        'json');
      }
      var newUser = [];
      function activity_screen_member() {
        var data = {
          'max_member_id': "undefined" != typeof $('.left_userlist .list_img ul li').eq(0).attr('data-id') ? $('.left_userlist .list_img ul li').eq(0).attr('data-id') : '0',
        };
        $.post("{php echo $this->createMobileUrl('redpack_member',array('rid'=>$rid,'rotate_id'=>$redpack['id']))}", data,
        function(e) {
          newUser = e.list;
          left_userlist_Roll();
        },
        'json');
      }
      left_userlist_Roll();
      left_userlist_Rank();
      function left_userlist_Rank() {
        var s = $('.left_userlist .list_img li').length - 1;
        $('.left_userlist .list_img li').each(function() {
          var i = $(this).index();
          $(this).css('bottom', (s - i) * 64);
        });
      }
      var ii = 0;
      function left_userlist_Roll() {
        if (newUser.length > 0 && ii < newUser.length && !$.isEmptyObject(newUser)) {

          $('.left_userlist .list_img ul').css({
            marginTop: '-64px'
          });
          $('.left_userlist .list_img ul').prepend('<li data-id="' + newUser[ii].id + '"><img src="' + newUser[ii].avatar + '" alt="' + newUser[ii].nick_name + '"></li>');
          $('.left_userlist .list_img ul').animate({
            marginTop: '0px'
          },
          500,
          function() {
            var userNum = parseInt($('.user_total b').text()) + 1;
            $('.user_total b').text(userNum);
            ii += 1;
            $('.left_userlist .list_img ul li:gt(5)').remove(); //如果超过6个参与用户头像，就进行移除
            setTimeout(left_userlist_Roll, 200);
            left_userlist_Rank();
          });
        } else {
          ii = 0;
          newUser = [];
         // setTimeout(activity_screen_member, 5000);
        }
      }
      var record_timer;
      var newWinning = [];
      function activity_screen_record(ttt) {
        newWinning = [];
        clearTimeout(record_timer);
        var data = {
          'max_record_id': "undefined" != typeof $('.right_winninglist dl dd.list ul li').eq(0).attr('data-id') ? $('.right_winninglist dl dd.list ul li').eq(0).attr('data-id') : '0',
        };
        $.post("{php echo $this->createMobileUrl('redpack_record',array('rid'=>$rid,'rotate_id'=>$redpack['id']))}", data,
        function(e) {
          if (e.is_end) {
            location.reload();
            return;
          }
          newWinning = e.list;
          if (ttt) {
            winning_list();
          } else {
            ani_winning();
          }
        },
        'json');
      }
      function winning_list() {
        if ($.isEmptyObject(newWinning)) {
          return;
        }
        for (var i = 0; i <= newWinning.length; i++) {
          //console.log(newWinning.length + '-----' + i);
          console.log(newWinning);
			var thtml = ''
			if(bd_show ==1 && lottory_show.length>0){
				for(var y=0;y<lottory_show.length;y++){
				 if(lottory_show[y]!='mobile'){
					thtml += "&nbsp;&nbsp;&nbsp;"+newWinning[i].bd_data[lottory_show[y]]||' ';	
				  }else{
					newWinning[i].bd_data[lottory_show[y]] = newWinning[i].bd_data[lottory_show[y]].replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
					thtml += "&nbsp;&nbsp;&nbsp;"+newWinning[i].bd_data[lottory_show[y]]||' ';
				  }
				}	
			}else{
				thtml += newWinning[i].nick_name;
			}
            prize_html = '<li class="money" data-id="' + newWinning[i].id + '">\
			<img src="' + newWinning[i].avatar + '" class="user_photo">\
			<div class="user_info">\
			<p>' + thtml + '</p>\
			<span>恭喜获得' + newWinning[i].money + '红包！</span>\
			</div>\
			<div class="money_bg"><b>' + newWinning[i].money + '</b></div>\
			</li>';
          
          $('.right_winninglist dl dd.list ul').prepend(prize_html);
        }
      }
      var jj = 0;
      var ani_winning_timer;
      function ani_winning() {
        if (newWinning.length > 0 && jj < newWinning.length && !$.isEmptyObject(newWinning)) {
          //console.log(newWinning.length + '--' + jj);
          //console.log(newWinning);
		  newWinning[jj].zzs = "{$redpack['zzs']}";
          newWinning[jj].zzs = newWinning[jj].zzs ? "本奖品由" + newWinning[jj].zzs + "提供": '';
          //console.log('1--------');
          //if (newWinning[jj].prize_type == 30 || newWinning[jj].prize_type == 31) {
            newWinning[jj].prize_pic = "{if !empty($redpack_config['money_bg'])}{php echo tomedia($redpack_config['money_bg'])}{else}{MODULE_URL}template/mobile/app/images/redpack/money_bg.jpg{/if}";
         // }
          $('.pop_winning .user_photo').attr({
            src: newWinning[jj].avatar
          });
          $('.pop_winning .prize_img').attr({
            src: newWinning[jj].prize_pic
          });
		  var thtml = ''
			if(bd_show ==1 && lottory_show.length>0){
				for(var o=0;o<lottory_show.length;o++){
				 if(lottory_show[o]!='mobile'){
					thtml += "&nbsp;&nbsp;&nbsp;"+newWinning[jj].bd_data[lottory_show[o]]||' ';	
				  }else{
					newWinning[jj].bd_data[lottory_show[o]] = newWinning[jj].bd_data[lottory_show[o]].replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
					thtml += "&nbsp;&nbsp;&nbsp;"+newWinning[jj].bd_data[lottory_show[o]]||' ';
				  }
				}	
			}else{
				thtml += newWinning[jj].nick_name;
			}
          $('.pop_winning .user_info p').html(thtml);
          $('.pop_winning .user_info span').text(newWinning[jj].zzs);
         // console.log('2--------');
          $('.pop_winning').show();
          $('.pop_winning').animate({
            opacity: '1'
          },
          700,
          function() {
           // console.log('3--------');
            $('.pop_winning').delay(1000).animate({
              marginLeft: '-140px',
              marginTop: '-100px',
              opacity: '0'
            },
            500,
            function() {
              $('.pop_winning').css({
                marginLeft: '-310px',
                marginTop: '0',
                display: 'none'
              });
              //console.log('4--------');
              var thtml2 = ''
				if(bd_show ==1 && lottory_show.length>0){
					for(var m=0;m<lottory_show.length;m++){
					 if(lottory_show[m]!='mobile'){
						thtml2 += "&nbsp;&nbsp;&nbsp;"+newWinning[jj].bd_data[lottory_show[m]]||' ';	
					  }else{
						newWinning[jj].bd_data[lottory_show[m]] = newWinning[jj].bd_data[lottory_show[m]].replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
						thtml2 += "&nbsp;&nbsp;&nbsp;"+newWinning[jj].bd_data[lottory_show[m]]||' ';
					  }
					}	
				}else{
					thtml2 += newWinning[jj].nick_name;
				}
                prize_html = '<li class="money" data-id="' + newWinning[jj].id + '">\
						<img src="' + newWinning[jj].avatar + '" class="user_photo">\
						<div class="user_info">\
						<p>' + thtml2 + '</p>\
						<span>恭喜获得' + newWinning[jj].money + '红包！</span>\
						</div>\
						<div class="money_bg"><b>' + newWinning[jj].money + '</b></div>\
						</li>';
             
              right_winninglist_Roll();
              jj += 1;
              ani_winning_timer = setTimeout(ani_winning, 100);
            });
          });
        } else {
          jj = 0;
          //record_timer = setTimeout(activity_screen_record, 2000);
        }
      }

      // 右侧中奖名单滚动效果
      function right_winninglist_Roll() {
        $('.right_winninglist dl dd.list ul').css({
          marginTop: '-80px'
        });
        $('.right_winninglist dl dd.list ul').prepend(prize_html);
        $('.right_winninglist dl dd.list ul').animate({
          marginTop: '0px'
        },
        500);
        $('.right_winninglist dl dd.list ul li:gt(4)').remove(); //如果超过5个中奖名单，就进行移除
      }*/
      function ani_redenvelop(elem, time) {
        $(elem).css({
          'top': '-160px',
          '-webkit-transition': 'top 0ms linear'
        });
        var mywidth = parseInt($(elem).width());
        var myleft = Math.random() * (290 - mywidth);
        var mytime = time * 0.7 + time * 0.3 * Math.random();
        $(elem).css({
          'left': myleft + 'px',
          'top': '100%',
          '-webkit-transition': 'top ' + mytime + 'ms linear'
        });
        redenvelop_timer = setTimeout("ani_redenvelop('" + elem + "','" + time + "')", mytime);
        if (parseInt($('.countNum b.sec').text()) <= 0) {
          clearInterval(redenvelop_timer);
        }
      } 
</script>
<script src="../addons/jy_h5game/resource/xianchang/js/screenfull.js" type="text/javascript"></script>
<script>
var f=false;
var idd;
$(function () {
$('.fullscreen').click(function () {
if(!f){
	screenfull.request($('#container')[0]);
	//$('.MsgList').css({"height":"100%","width":"100%"});

	f = true;
}else{
	f = false;
	//$('.MsgList').css({"height":"74%","width":"90%"});
	screenfull.exit();
}
});
$('#exit').click(function () {
	screenfull.exit();
});
$(document).on(screenfull.raw.fullscreenchange, function () { 
	if (!screenfull.isFullscreen) {
		 f = false;
		 $('.bottom_sphere,.bottom_money,.bottom_phone').css({
		"bottom":"0"});
	}else{
		 f = true;
		 $('.bottom_sphere,.bottom_money,.bottom_phone').css({
		"bottom":"0"});
	}
});
});
</script>